package com.sghd.fight.module.game.service.work;

import com.sghd.common.utils.concurrent.DelayedElement;
import com.sghd.fight.module.game.service.room.IRoom;

import java.util.Date;
import java.util.Objects;

/**
 * 超时任务
 */
public class RoomWork extends DelayedElement<RoomRunner> {

    public static final int ROOM = 1;
    public static final int MATCH = 2;

    /**房间id*/
    private IRoom room;
    /**类型*/
    private int type;

    public RoomWork(IRoom room, RoomRunner runner, Date end) {
        super(runner, end);
        this.type = ROOM;
        this.room = room;
    }

    public RoomWork(RoomRunner runner, Date end, int type) {
        super(runner, end);
        this.type = type;
    }

    public IRoom getRoom() {
        return room;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        RoomWork roomWork = (RoomWork) o;
        return type == roomWork.type &&
                Objects.equals(room, roomWork.room);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), room, type);
    }

    public int getType() {
        return type;
    }

}
